package com.itheima.day04;

import java.util.Scanner;

public class Demo9 {
    public static void main(String[] args) {
//        checkPhone();
        while (true) {
            checkMoney();
        }
    }

    public static void checkPhone() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("请输入您的手机号:");
            String s = scanner.next();
            boolean matches = s.matches("1[3-9]\\w{9}");
            if (matches) {
                System.out.println("注册成功");
                return;
            }else {
                System.out.println("格式不对,请重新输入");
            }
        }

    }

    public static void checkGmail() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("请输入您的邮箱号:");
            String s = scanner.next();
            boolean matches = s.matches("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");
            if (matches) {
                System.out.println("注册成功");
                return;
            }else {
                System.out.println("格式不对,请重新输入");
            }
        }

    }

    public static void checkTelephone() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("请输入您的电话号:");
            String s = scanner.next();
            boolean matches = s.matches("0\\d{2,6}-?\\d{2,20}");
            if (matches) {
                System.out.println("注册成功");
                return;
            }else {
                System.out.println("格式不对,请重新输入");
            }
        }

    }

    public static void checkMoney() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("请输入您的金额:");
            String s = scanner.next();
            boolean matches = s.matches("\\d{1,}\\.?\\d{1,}");
            if (matches) {
                System.out.println("正确");
                return;
            }else {
                System.out.println("格式不对,请重新输入");
            }
        }

    }
}
